package com.study.design.pattern.pattern.behavioral.command;

/**
 * @Author: gongsl
 * @Date: 2025-03-24 23:22
 * @description: 调用者-遥控器：支持撤销
 */
public class RemoteControl {
    private Command lastCommand;

    public void setCommand(Command command) {
        this.lastCommand = command;
    }

    public void pressButton() {
        if (lastCommand != null) {
            lastCommand.execute();
        }
    }

    public void pressUndo() {
        if (lastCommand != null) {
            lastCommand.undo();
        }
    }
}
